#include <stdio.h> 
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

#include <sys/types.h>

#include <unistd.h>

#include <fcntl.h>

#include <linux/ioctl.h>
int main()

{

    int fd,i,nwrite,nread;

    char *buf ="hello\n";

    char read_buf[6]= {0};

    fd=open("/dev/test_dev",O_RDWR);

    if(fd<=0)

    {

	printf("%d",fd);
        perror("open");

        exit(1);

    }

    else                         printf("open success\n");

    nwrite = write(fd,buf,strlen(buf));

    if(nwrite<0)

    {

        perror("write");

        exit(1);

    }

    nread = read(fd,read_buf,6);
    
if(nread<0)

    {

        perror("read");

        exit(1);

    }

    else

        printf("read is %s\n",read_buf);
 close(fd);

    exit(0);

}


